|
1
|
|
|
/*jslint |
|
2
|
|
|
indent: 4 |
|
3
|
|
|
*/ |
|
4
|
|
|
|
|
5
|
|
|
/*global |
|
6
|
|
|
$, google, Lang, Lines, Markers, Conversion, Cookies, Coordinates, trackMarker, showAlert, |
|
7
|
|
|
id2alpha, alpha2id, |
|
8
|
|
|
showProjectionDialog, showLinkDialog, |
|
9
|
|
|
osmProvider, osmDeProvider, thunderforestProvider, opentopomapProvider, |
|
10
|
|
|
get_cookie_int, get_cookie_float, get_cookie_string, |
|
11
|
|
|
Attribution, Sidebar, ExternalLinks, Hillshading, Geolocation, NPA, CDDA, Freifunk, Okapi, |
|
12
|
|
|
DownloadGPX, API_KEY_THUNDERFOREST, |
|
13
|
|
|
restoreCoordinatesFormat, |
|
14
|
|
|
document, window |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
//var boundariesLayer = null; |
|
19
|
|
|
//var boundariesLayerShown = false; |
|
20
|
|
|
var CLAT_DEFAULT = 51.163375; |
|
21
|
|
|
var CLON_DEFAULT = 10.447683; |
|
22
|
|
|
var ZOOM_DEFAULT = 12; |
|
23
|
|
|
var ZOOM_DEFAULT_GEOCACHE = 15; |
|
24
|
|
|
var MAPTYPE_DEFAULT = "OSM"; |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
var App = {}; |
|
28
|
|
|
App.m_map = null; |
|
29
|
|
|
|
|
30
|
|
|
App.urlParams = function () { |
|
31
|
|
|
'use strict'; |
|
32
|
|
|
|
|
33
|
|
|
var params = {}, |
|
34
|
|
|
splitted = window.location.search.substr(1).split('&'), |
|
35
|
|
|
i, |
|
36
|
|
|
p; |
|
37
|
|
|
|
|
38
|
|
|
for (i = 0; i < splitted.length; i += 1) { |
|
39
|
|
|
p = splitted[i].split('=', 2); |
|
40
|
|
|
if (p[0] !== "") { |
|
41
|
|
|
if (p.length === 1) { |
|
42
|
|
|
params[p[0]] = ""; |
|
43
|
|
|
} else { |
|
44
|
|
|
params[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " ")); |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
return params; |
|
50
|
|
|
}; |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
App.init = function () { |
|
54
|
|
|
'use strict'; |
|
55
|
|
|
|
|
56
|
|
|
Lang.init(); |
|
57
|
|
|
|
|
58
|
|
|
var params = App.urlParams(); |
|
59
|
|
|
if (!App.initFromUrl(params)) { |
|
60
|
|
|
App.initFromCookies(); |
|
61
|
|
|
} |
|
62
|
|
|
}; |
|
63
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
App.initFromUrl = function (params) { |
|
66
|
|
|
'use strict'; |
|
67
|
|
|
|
|
68
|
|
|
if (params.c === undefined && |
|
69
|
|
|
params.z === undefined && |
|
70
|
|
|
params.t === undefined && |
|
71
|
|
|
params.m === undefined && |
|
72
|
|
|
params.d === undefined && |
|
73
|
|
|
params.f === undefined && |
|
74
|
|
|
params.g === undefined) { |
|
75
|
|
|
return false; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
var center = this.parseCenterFromUrl(params.c), |
|
79
|
|
|
zoom = this.repairZoom(parseInt(params.z, 10), (params.g === undefined) ? ZOOM_DEFAULT : ZOOM_DEFAULT_GEOCACHE), |
|
80
|
|
|
maptype = this.repairMaptype(params.t, MAPTYPE_DEFAULT), |
|
81
|
|
|
markerdata = this.parseMarkersFromUrl(params.m), |
|
82
|
|
|
defaultCenter = false; |
|
83
|
|
|
|
|
84
|
|
|
if (!center && markerdata.length > 0) { |
|
85
|
|
|
var clat = 0, |
|
86
|
|
|
clng = 0; |
|
87
|
|
|
markerdata.map(function (m) { |
|
88
|
|
|
clat += m.coords.lat(); |
|
89
|
|
|
clng += m.coords.lng(); |
|
90
|
|
|
}); |
|
91
|
|
|
center = new google.maps.LatLng(clat / markerdata.length, clng / markerdata.length); |
|
92
|
|
|
} |
|
93
|
|
|
if (!center) { |
|
94
|
|
|
center = new google.maps.LatLng(CLAT_DEFAULT, CLON_DEFAULT); |
|
95
|
|
|
defaultCenter = true; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
App.m_map = this.createMap("themap", center, zoom, maptype); |
|
99
|
|
|
|
|
100
|
|
|
markerdata.map(function (m) { |
|
101
|
|
|
Markers.newMarker(m.coords, m.id, m.r, m.name, m.color); |
|
102
|
|
|
}); |
|
103
|
|
|
|
|
104
|
|
|
this.parseLinesFromUrl(params.d).map(function (m) { |
|
105
|
|
|
Lines.newLine(m.source, m.target); |
|
106
|
|
|
}); |
|
107
|
|
|
|
|
108
|
|
|
App.restore(params.f, params.g); |
|
109
|
|
|
|
|
110
|
|
|
if (defaultCenter && params.g !== undefined) { |
|
111
|
|
|
Geolocation.whereAmI(); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
return true; |
|
115
|
|
|
}; |
|
116
|
|
|
|
|
117
|
|
|
|
|
118
|
|
|
App.initFromCookies = function () { |
|
119
|
|
|
'use strict'; |
|
120
|
|
|
|
|
121
|
|
|
var clat = this.repairLat(get_cookie_float('clat', CLAT_DEFAULT)), |
|
122
|
|
|
clon = this.repairLon(get_cookie_float('clon', CLON_DEFAULT)), |
|
123
|
|
|
defaultCenter = (clat === CLAT_DEFAULT && clon === CLON_DEFAULT), |
|
124
|
|
|
center = new google.maps.LatLng(clat, clon), |
|
125
|
|
|
zoom = this.repairZoom(get_cookie_int('zoom', ZOOM_DEFAULT), ZOOM_DEFAULT), |
|
126
|
|
|
maptype = this.repairMaptype(get_cookie_string('maptype', MAPTYPE_DEFAULT), MAPTYPE_DEFAULT); |
|
127
|
|
|
|
|
128
|
|
|
|
|
129
|
|
|
App.m_map = this.createMap("themap", center, zoom, maptype); |
|
130
|
|
|
|
|
131
|
|
|
this.parseMarkersFromCookies().map(function (m) { |
|
132
|
|
|
Markers.newMarker(m.coords, m.id, m.r, m.name, m.color); |
|
133
|
|
|
}); |
|
134
|
|
|
|
|
135
|
|
|
this.parseLinesFromCookies().map(function (m) { |
|
136
|
|
|
Lines.newLine(m.source, m.target); |
|
137
|
|
|
}); |
|
138
|
|
|
|
|
139
|
|
|
App.restore(undefined); |
|
140
|
|
|
|
|
141
|
|
|
if (defaultCenter) { |
|
142
|
|
|
Geolocation.whereAmI(); |
|
143
|
|
|
} |
|
144
|
|
|
}; |
|
145
|
|
|
|
|
146
|
|
|
|
|
147
|
|
|
App.restore = function (features, geocache) { |
|
148
|
|
|
'use strict'; |
|
149
|
|
|
|
|
150
|
|
|
if (geocache !== undefined) { |
|
151
|
|
|
Okapi.setShowCache(geocache); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
Sidebar.restore(true); |
|
155
|
|
|
|
|
156
|
|
|
if (features === undefined) { |
|
157
|
|
|
Hillshading.restore(false); |
|
158
|
|
|
//restoreBoundaries(false); |
|
159
|
|
|
Okapi.restore(false); |
|
160
|
|
|
NPA.toggle(false); |
|
161
|
|
|
CDDA.toggle(false); |
|
162
|
|
|
Freifunk.toggle(false); |
|
163
|
|
|
} else { |
|
164
|
|
|
features = features.toLowerCase(); |
|
165
|
|
|
Hillshading.toggle(features.indexOf('h') >= 0); |
|
166
|
|
|
//toggleBoundaries(xfeatures.indexOf('b') >= 0); |
|
167
|
|
|
Okapi.toggle(features.indexOf('g') >= 0); |
|
168
|
|
|
NPA.toggle(features.indexOf('n') >= 0); |
|
169
|
|
|
Freifunk.toggle(features.indexOf('f') >= 0); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
restoreCoordinatesFormat("DM"); |
|
173
|
|
|
|
|
174
|
|
|
if (geocache !== undefined) { |
|
175
|
|
|
Okapi.toggle(true); |
|
176
|
|
|
} |
|
177
|
|
|
}; |
|
178
|
|
|
|
|
179
|
|
|
|
|
180
|
|
|
App.storeCenter = function () { |
|
181
|
|
|
'use strict'; |
|
182
|
|
|
|
|
183
|
|
|
var c = App.m_map.getCenter(); |
|
184
|
|
|
Cookies.set('clat', c.lat(), {expires: 30}); |
|
185
|
|
|
Cookies.set('clon', c.lng(), {expires: 30}); |
|
186
|
|
|
}; |
|
187
|
|
|
|
|
188
|
|
|
|
|
189
|
|
|
App.storeZoom = function () { |
|
190
|
|
|
'use strict'; |
|
191
|
|
|
|
|
192
|
|
|
Cookies.set('zoom', App.m_map.getZoom(), {expires: 30}); |
|
193
|
|
|
}; |
|
194
|
|
|
|
|
195
|
|
|
|
|
196
|
|
|
App.storeMapType = function () { |
|
197
|
|
|
'use strict'; |
|
198
|
|
|
|
|
199
|
|
|
Cookies.set('maptype', App.m_map.getMapTypeId(), {expires: 30}); |
|
200
|
|
|
}; |
|
201
|
|
|
|
|
202
|
|
|
|
|
203
|
|
|
App.getFeaturesString = function () { |
|
204
|
|
|
'use strict'; |
|
205
|
|
|
|
|
206
|
|
|
var s = ""; |
|
207
|
|
|
//if ($('#boundaries').is(':checked')) { s += "b"; } |
|
208
|
|
|
if ($('#geocaches').is(':checked')) { |
|
209
|
|
|
s += "g"; |
|
210
|
|
|
} |
|
211
|
|
|
if ($('#hillshading').is(':checked')) { |
|
212
|
|
|
s += "h"; |
|
213
|
|
|
} |
|
214
|
|
|
if ($('#npa').is(':checked')) { |
|
215
|
|
|
s += "n"; |
|
216
|
|
|
} |
|
217
|
|
|
if ($('#freifunk').is(':checked')) { |
|
218
|
|
|
s += "f"; |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
return s; |
|
222
|
|
|
}; |
|
223
|
|
|
|
|
224
|
|
|
|
|
225
|
|
|
App.getPermalink = function () { |
|
226
|
|
|
'use strict'; |
|
227
|
|
|
|
|
228
|
|
|
var lat = App.m_map.getCenter().lat(), |
|
229
|
|
|
lng = App.m_map.getCenter().lng(), |
|
230
|
|
|
geocache = Okapi.popupCacheCode(), |
|
231
|
|
|
url = "https://flopp.net/" + |
|
232
|
|
|
"?c=" + lat.toFixed(6) + ":" + lng.toFixed(6) + |
|
233
|
|
|
"&z=" + App.m_map.getZoom() + |
|
234
|
|
|
"&t=" + App.m_map.getMapTypeId() + |
|
235
|
|
|
"&f=" + this.getFeaturesString() + |
|
236
|
|
|
"&m=" + Markers.toString() + |
|
237
|
|
|
"&d=" + Lines.getLinesText(); |
|
238
|
|
|
if (geocache) { |
|
239
|
|
|
url += "&g=" + geocache; |
|
240
|
|
|
} |
|
241
|
|
|
return url; |
|
242
|
|
|
}; |
|
243
|
|
|
|
|
244
|
|
|
App.generatePermalink = function () { |
|
245
|
|
|
'use strict'; |
|
246
|
|
|
|
|
247
|
|
|
var link = this.getPermalink(); |
|
248
|
|
|
showLinkDialog(link); |
|
249
|
|
|
}; |
|
250
|
|
|
|
|
251
|
|
|
|
|
252
|
|
|
App.repairLat = function (x, d) { |
|
253
|
|
|
'use strict'; |
|
254
|
|
|
|
|
255
|
|
|
if (Coordinates.validLat(x)) { |
|
256
|
|
|
return x; |
|
257
|
|
|
} |
|
258
|
|
|
|
|
259
|
|
|
return d; |
|
260
|
|
|
}; |
|
261
|
|
|
|
|
262
|
|
|
|
|
263
|
|
|
App.repairLon = function (x, d) { |
|
264
|
|
|
'use strict'; |
|
265
|
|
|
|
|
266
|
|
|
if (Coordinates.validLng(x)) { |
|
267
|
|
|
return x; |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
return d; |
|
271
|
|
|
}; |
|
272
|
|
|
|
|
273
|
|
|
|
|
274
|
|
|
App.repairRadius = function (x, d) { |
|
275
|
|
|
'use strict'; |
|
276
|
|
|
|
|
277
|
|
|
if (x === null || isNaN(x) || x < 0 || x > 100000000) { |
|
278
|
|
|
return d; |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
return x; |
|
282
|
|
|
}; |
|
283
|
|
|
|
|
284
|
|
|
|
|
285
|
|
|
App.repairZoom = function (x, d) { |
|
286
|
|
|
'use strict'; |
|
287
|
|
|
|
|
288
|
|
|
if (x === undefined || x === null || isNaN(x) || x < 1 || x > 20) { |
|
289
|
|
|
return d; |
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
|
|
return x; |
|
293
|
|
|
}; |
|
294
|
|
|
|
|
295
|
|
|
|
|
296
|
|
|
App.repairMaptype = function (t, d) { |
|
297
|
|
|
'use strict'; |
|
298
|
|
|
|
|
299
|
|
|
var mapTypes = { |
|
300
|
|
|
"OSM": 1, |
|
301
|
|
|
"OSM/DE": 1, |
|
302
|
|
|
"OCM": 1, |
|
303
|
|
|
"OUTD": 1, |
|
304
|
|
|
"TOPO": 1, |
|
305
|
|
|
"satellite": 1, |
|
306
|
|
|
"hybrid": 1, |
|
307
|
|
|
"roadmap": 1, |
|
308
|
|
|
"terrain": 1 |
|
309
|
|
|
}; |
|
310
|
|
|
|
|
311
|
|
|
if (t !== undefined && mapTypes[t]) { |
|
312
|
|
|
return t; |
|
313
|
|
|
} |
|
314
|
|
|
|
|
315
|
|
|
return d; |
|
316
|
|
|
}; |
|
317
|
|
|
|
|
318
|
|
|
|
|
319
|
|
|
App.parseMarkersFromUrl = function (urlarg) { |
|
320
|
|
|
'use strict'; |
|
321
|
|
|
|
|
322
|
|
|
if (!urlarg) { |
|
323
|
|
|
return []; |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
var data; |
|
327
|
|
|
|
|
328
|
|
|
// ID:COODRS:R(:NAME)?|ID:COORDS:R(:NAME)? |
|
329
|
|
|
// COORDS=LAT:LON or DEG or DMMM |
|
330
|
|
|
if (urlarg.indexOf("*") >= 0) { |
|
331
|
|
|
data = urlarg.split('*'); |
|
332
|
|
|
} else { |
|
333
|
|
|
/* sep is '|' */ |
|
334
|
|
|
data = urlarg.split('|'); |
|
335
|
|
|
} |
|
336
|
|
|
|
|
337
|
|
|
return data.map(function (dataitem) { |
|
338
|
|
|
dataitem = dataitem.split(':'); |
|
339
|
|
|
if (dataitem.length < 3 || dataitem.length > 6) { |
|
340
|
|
|
return null; |
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
var m = { |
|
344
|
|
|
alpha: dataitem[0], |
|
345
|
|
|
id: alpha2id(dataitem[0]), |
|
346
|
|
|
name: null, |
|
347
|
|
|
coords: null, |
|
348
|
|
|
r: 0, |
|
349
|
|
|
color: "" |
|
350
|
|
|
}, |
|
351
|
|
|
index = 1, |
|
352
|
|
|
lat, |
|
353
|
|
|
lon; |
|
354
|
|
|
|
|
355
|
|
|
if (m.id < 0) { |
|
356
|
|
|
return null; |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
lat = parseFloat(dataitem[index]); |
|
360
|
|
|
lon = parseFloat(dataitem[index + 1]); |
|
361
|
|
|
if (Coordinates.valid(lat, lon)) { |
|
362
|
|
|
index += 2; |
|
363
|
|
|
m.coords = new google.maps.LatLng(lat, lon); |
|
364
|
|
|
} else { |
|
365
|
|
|
m.coords = Coordinates.fromString(dataitem[index]); |
|
366
|
|
|
index += 1; |
|
367
|
|
|
} |
|
368
|
|
|
if (!m.coords) { |
|
369
|
|
|
return null; |
|
370
|
|
|
} |
|
371
|
|
|
|
|
372
|
|
|
m.r = App.repairRadius(parseFloat(dataitem[index]), 0); |
|
373
|
|
|
index = index + 1; |
|
374
|
|
|
|
|
375
|
|
|
if (index < dataitem.length && |
|
376
|
|
|
(/^([a-zA-Z0-9\-_]*)$/).test(dataitem[index])) { |
|
377
|
|
|
m.name = dataitem[index]; |
|
378
|
|
|
} |
|
379
|
|
|
|
|
380
|
|
|
index = index + 1; |
|
381
|
|
|
if (index < dataitem.length && |
|
382
|
|
|
(/^([a-fA-F0-9]{6})$/).test(dataitem[index])) { |
|
383
|
|
|
m.color = dataitem[index]; |
|
384
|
|
|
} |
|
385
|
|
|
|
|
386
|
|
|
return m; |
|
387
|
|
|
}).filter(function (thing) { |
|
388
|
|
|
return thing !== null; |
|
389
|
|
|
}); |
|
390
|
|
|
}; |
|
391
|
|
|
|
|
392
|
|
|
|
|
393
|
|
|
App.parseCenterFromUrl = function (urlarg) { |
|
394
|
|
|
'use strict'; |
|
395
|
|
|
|
|
396
|
|
|
if (!urlarg) { |
|
397
|
|
|
return null; |
|
398
|
|
|
} |
|
399
|
|
|
|
|
400
|
|
|
var data = urlarg.split(':'); |
|
401
|
|
|
|
|
402
|
|
|
if (data.length === 1) { |
|
403
|
|
|
return Coordinates.fromString(data[0]); |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
if (data.length === 2) { |
|
407
|
|
|
return Coordinates.toLatLng(parseFloat(data[0]), parseFloat(data[1])); |
|
408
|
|
|
} |
|
409
|
|
|
|
|
410
|
|
|
return null; |
|
411
|
|
|
}; |
|
412
|
|
|
|
|
413
|
|
|
|
|
414
|
|
|
App.parseLinesFromUrl = function (urlarg) { |
|
415
|
|
|
'use strict'; |
|
416
|
|
|
|
|
417
|
|
|
if (urlarg === undefined || urlarg === null) { |
|
418
|
|
|
return []; |
|
419
|
|
|
} |
|
420
|
|
|
|
|
421
|
|
|
/* be backwards compatible */ |
|
422
|
|
|
if (urlarg.length === 3 |
|
423
|
|
|
&& alpha2id(urlarg[0]) >= 0 |
|
424
|
|
|
&& urlarg[1] === '*' |
|
425
|
|
|
&& alpha2id(urlarg[1]) >= 0) { |
|
426
|
|
|
urlarg = urlarg[0] + ':' + urlarg[2]; |
|
427
|
|
|
} |
|
428
|
|
|
|
|
429
|
|
|
return urlarg.split('*').map(function (pair_string) { |
|
430
|
|
|
var pair = pair_string.split(':'); |
|
431
|
|
|
if (pair.length === 2) { |
|
432
|
|
|
return {source: alpha2id(pair[0]), target: alpha2id(pair[1])}; |
|
433
|
|
|
} |
|
434
|
|
|
return null; |
|
435
|
|
|
}).filter(function (thing) { |
|
436
|
|
|
return (thing !== null); |
|
437
|
|
|
}); |
|
438
|
|
|
}; |
|
439
|
|
|
|
|
440
|
|
|
|
|
441
|
|
|
App.parseMarkersFromCookies = function () { |
|
442
|
|
|
'use strict'; |
|
443
|
|
|
|
|
444
|
|
|
var raw_ids = Cookies.get('markers'); |
|
445
|
|
|
|
|
446
|
|
|
if (!raw_ids) { |
|
447
|
|
|
return []; |
|
448
|
|
|
} |
|
449
|
|
|
|
|
450
|
|
|
return raw_ids.split(':').map(function (id_string) { |
|
451
|
|
|
var m = {id: null, name: null, coords: null, r: 0, color: ""}, |
|
452
|
|
|
raw_data, |
|
453
|
|
|
data; |
|
454
|
|
|
|
|
455
|
|
|
m.id = parseInt(id_string, 10); |
|
456
|
|
|
if (m.id === null || m.id < 0 || m.id >= 26 * 10) { |
|
457
|
|
|
return null; |
|
458
|
|
|
} |
|
459
|
|
|
|
|
460
|
|
|
raw_data = Cookies.get('marker' + m.id); |
|
461
|
|
|
if (!raw_data) { |
|
462
|
|
|
return null; |
|
463
|
|
|
} |
|
464
|
|
|
|
|
465
|
|
|
data = raw_data.split(':'); |
|
466
|
|
|
if (data.length !== 4 && data.length !== 5) { |
|
467
|
|
|
return null; |
|
468
|
|
|
} |
|
469
|
|
|
|
|
470
|
|
|
m.coords = Coordinates.toLatLng(parseFloat(data[0]), parseFloat(data[1])); |
|
471
|
|
|
if (!m.coords) { |
|
472
|
|
|
return null; |
|
473
|
|
|
} |
|
474
|
|
|
|
|
475
|
|
|
m.r = App.repairRadius(parseFloat(data[2]), 0); |
|
476
|
|
|
|
|
477
|
|
|
if ((/^([a-zA-Z0-9\-_]*)$/).test(data[3])) { |
|
478
|
|
|
m.name = data[3]; |
|
479
|
|
|
} |
|
480
|
|
|
|
|
481
|
|
|
if (data.length === 5 && (/^([a-fA-F0-9]{6})$/).test(data[4])) { |
|
482
|
|
|
m.color = data[4]; |
|
483
|
|
|
} |
|
484
|
|
|
|
|
485
|
|
|
return m; |
|
486
|
|
|
}).filter(function (thing) { |
|
487
|
|
|
return (thing !== null); |
|
488
|
|
|
}); |
|
489
|
|
|
}; |
|
490
|
|
|
|
|
491
|
|
|
|
|
492
|
|
|
App.parseLinesFromCookies = function () { |
|
493
|
|
|
'use strict'; |
|
494
|
|
|
|
|
495
|
|
|
var raw_lines = Cookies.get('lines'); |
|
496
|
|
|
|
|
497
|
|
|
if (!raw_lines) { |
|
498
|
|
|
return []; |
|
499
|
|
|
} |
|
500
|
|
|
|
|
501
|
|
|
return raw_lines.split('*').map(function (pair_string) { |
|
502
|
|
|
var pair = pair_string.split(':'); |
|
503
|
|
|
if (pair.length === 2) { |
|
504
|
|
|
return {source: alpha2id(pair[0]), target: alpha2id(pair[1])}; |
|
505
|
|
|
} |
|
506
|
|
|
return null; |
|
507
|
|
|
}).filter(function (thing) { |
|
508
|
|
|
return (thing !== null); |
|
509
|
|
|
}); |
|
510
|
|
|
}; |
|
511
|
|
|
|
|
512
|
|
|
|
|
513
|
|
|
App.createMap = function (id, center, zoom, maptype) { |
|
514
|
|
|
'use strict'; |
|
515
|
|
|
|
|
516
|
|
|
var m = new google.maps.Map( |
|
517
|
|
|
document.getElementById(id), |
|
518
|
|
|
{ |
|
519
|
|
|
zoom: zoom, |
|
520
|
|
|
center: center, |
|
521
|
|
|
scaleControl: true, |
|
522
|
|
|
streetViewControl: false, |
|
523
|
|
|
mapTypeControlOptions: {mapTypeIds: ['OSM', 'OSM/DE', 'OCM', 'OUTD', 'TOPO', google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.TERRAIN]}, |
|
524
|
|
|
mapTypeId: google.maps.MapTypeId.ROADMAP |
|
525
|
|
|
} |
|
526
|
|
|
); |
|
527
|
|
|
|
|
528
|
|
|
m.mapTypes.set("OSM", osmProvider("OSM")); |
|
529
|
|
|
m.mapTypes.set("OSM/DE", osmDeProvider("OSM/DE")); |
|
530
|
|
|
m.mapTypes.set("OCM", thunderforestProvider("OCM", "cycle", API_KEY_THUNDERFOREST)); |
|
531
|
|
|
m.mapTypes.set("OUTD", thunderforestProvider("OUTD", "outdoors", API_KEY_THUNDERFOREST)); |
|
532
|
|
|
m.mapTypes.set("TOPO", opentopomapProvider("TOPO")); |
|
533
|
|
|
m.setMapTypeId(maptype); |
|
534
|
|
|
|
|
535
|
|
|
Attribution.init(m); |
|
536
|
|
|
Sidebar.init(m); |
|
537
|
|
|
ExternalLinks.init(m); |
|
538
|
|
|
Markers.init(m); |
|
539
|
|
|
Lines.init(m); |
|
540
|
|
|
Geolocation.init(m); |
|
541
|
|
|
Hillshading.init(m); |
|
542
|
|
|
NPA.init(m); |
|
543
|
|
|
CDDA.init(m); |
|
544
|
|
|
Freifunk.init(m); |
|
545
|
|
|
Okapi.init(m); |
|
546
|
|
|
DownloadGPX.init(m); |
|
547
|
|
|
|
|
548
|
|
|
//boundariesLayer = new google.maps.ImageMapType({ |
|
549
|
|
|
// getTileUrl: function(coord, zoom) { |
|
550
|
|
|
// if (6 <= zoom && zoom <= 16) |
|
551
|
|
|
// { |
|
552
|
|
|
// return tileUrl("http://korona.geog.uni-heidelberg.de/tiles/adminb/?x=%x&y=%y&z=%z", ["dummy"], coord, zoom); |
|
553
|
|
|
// } |
|
554
|
|
|
// else |
|
555
|
|
|
// { |
|
556
|
|
|
// return null; |
|
557
|
|
|
// } |
|
558
|
|
|
// }, |
|
559
|
|
|
// tileSize: new google.maps.Size(256, 256), |
|
560
|
|
|
// name: "adminb", |
|
561
|
|
|
// alt: "Administrative Boundaries", |
|
562
|
|
|
// maxZoom: 16 }); |
|
563
|
|
|
|
|
564
|
|
|
m.setCenter(center, zoom); |
|
565
|
|
|
|
|
566
|
|
|
google.maps.event.addListener(m, "center_changed", function () { |
|
567
|
|
|
App.storeZoom(); |
|
568
|
|
|
App.storeCenter(); |
|
569
|
|
|
}); |
|
570
|
|
|
google.maps.event.addListener(m, "zoom_changed", function () { |
|
571
|
|
|
App.storeZoom(); |
|
572
|
|
|
App.storeCenter(); |
|
573
|
|
|
}); |
|
574
|
|
|
google.maps.event.addListener(m, "maptypeid_changed", function () { |
|
575
|
|
|
App.storeMapType(); |
|
576
|
|
|
}); |
|
577
|
|
|
|
|
578
|
|
|
Attribution.forceUpdate(); |
|
579
|
|
|
|
|
580
|
|
|
return m; |
|
581
|
|
|
}; |
|
582
|
|
|
|